{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 45 Spark编程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.【选择】请选出创建SparkSession对象的正确代码：（ ）  \n",
    "\n",
    "A.  \n",
    "`mySpark = SparkSession.builder\n",
    "    .appName('My_App')\n",
    "    .master('local')\n",
    "    .getOrCreate()`  \n",
    "B.  \n",
    "`mySpark = SparkSession.builder\n",
    "    .appName('My_A p p')\\\n",
    "    .master('local')\\\n",
    "    .getOrCreate()\\`  \n",
    "C.  \n",
    "`mySpark = SparkSession.builder\\\n",
    "    .appName('My_App')\\\n",
    "    .master('local')\\\n",
    "    .getOrCreate()`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：C"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.【填空】查看RDD之间的继承关系可以用函数（ ）。 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：.explain()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.【填空】请在括号中填写合适的代码。（ ）  \n",
    "\n",
    "df = mySpark.read.csv('flights.csv', header=True)  \n",
    "#进行缓存处理  \n",
    "（ ）  \n",
    "df.show(5)  \n",
    "df.columns  \n",
    "df.count() \n",
    "#将数据转换为本地数据框   \n",
    "local_df=（ ）  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：  \n",
    "df.cache()  \n",
    "df.toPandas()"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
